<?php

class LoginController extends Zend_Controller_Action
{

	public function init()
	{
		/* Initialize action controller here */
	}

	public function indexAction()
	{ 
		$this->_helper->layout->disableLayout();
		$form = new Application_Form_LoginForm();
		$this->view->form = $form;
		 	
		if(Zend_Auth::getInstance()->hasIdentity()){
			$auth = Zend_Auth::getInstance();
		    $auth->clearIdentity();
		  }
			
		if($this->_request->isPost()){
			$dados = $this->_request->getPost();
				
			if($form->isValid($dados)){
					
				$authlogin = new Application_Model_LoginModel();
				if($authlogin->authLogin($form->login->getValue(),$form->senha->getValue())== TRUE){
					$this->_redirect('/');
				}
				else {
					echo 'Usuario ou Senha Invalida';
				}
			}
		}
	}




}

